﻿<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Kill Excel的进程</title>
    
</head>
<body>
<input type="button" value="关闭Excel" name="btn" onclick="StartExcel()" />
<script type="text/javascript" language="JavaScript">
    var idTmr = "";
    function StartExcel(){
        var oExcel;
        oExcel = new ActiveXObject("Excel.Application");    // 创建Excel对象
        oExcel.Quit();  // 关闭excel
        oExcel = null;  // 释放对象
        idTmr = window.setInterval("QuitExcel();",1);   // 定时清除
    }
    function QuitExcel(){
        window.clearInterval(idTmr);
        // 清除定时器
        CollectGarbage();   // kill进程
    }

</script>

</body>
</html>